package com.ledtechdesign.beans.api;

import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
import java.util.Date;

import org.apache.commons.beanutils.BeanUtils;

public abstract class BeanBase implements IResult {

	// TODO move this to some sane place
	public static String MEET_INFO_DATE_FORMAT = "EEE MMM dd HH:mm:ss zzz yyyy";

	public void convertStringToDate(String param, String fname) {

		if (param == null || param.trim().equalsIgnoreCase("NULL")) {
			return;
		}
		try {
			Date d = new java.text.SimpleDateFormat(MEET_INFO_DATE_FORMAT)
					.parse(param);
			BeanUtils.setProperty(this, fname, d);

		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void print() {
		System.out.println(this.toString());
		// TODO Auto-generated method stub
	}
}
